package search.model;

public class WordRankable implements Comparable<WordRankable> {
	private String word;
	private float score;

	public WordRankable(String word) {
		this.word = word;
		score = 0;
	}

	public String getWord() {
		return word;
	}

	public float getScore() {
		return score;
	}

	public void addScore(float score) {
		this.score += score;
	}

	@Override
	public int hashCode() {
		return word.hashCode();
	}

	public boolean equals(Object o) {
		if(o instanceof WordRankable) {
			WordRankable wrdRkble = (WordRankable)o;
			return word.equals(wrdRkble.getWord());
		}
		return false;
	}

	@Override
	public int compareTo(WordRankable o) {
		if(this.word.equals(o.word)) {
			return 0;
		}
		return score < o.score ? -1 : 1;
	}
}
